3. Getting Started with Micro:bit
=================================
3.1 Resource download
---------------------
**Download resource :** :download:`Microbit <./Microbit.7z>`
**The resource includes code and Cool Term, please obtain it first
before continuing to study.**
The following instructions are applied for Windows system but can also
serve as a reference if you are using a different system.
3.2 Write code and program
--------------------------
This chapter describes how to write program with the App Micro: Bit and
load the program to the Micro: Bit main board V2.
You are recommended to browse the official website of Micro:bit for more
details, and the link is attached below:
`https://microbit.org/guide/quick/ `__
**Step 1: connect the Micro: Bit main board V2 with your computer**
Firstly, link the Micro: Bit main board V2 with your computer via the
USB cable. Macs、PCs、 Chromebooks and Linux (including Raspberry
Pi)systems are all compatible with the Micro: Bit main board V2.
Note that if you are about to pair the board with your phone or tablet,
please refer to this link:
`https://microbit.org/get-started/user-guide/mobile/ <./https://microbit.org/get-started/user-guide/mobile/>`__
|image1|
Secondly, if the red LED on the back of the board is on, that means the
board is powered. Then Micro: Bit main board V2 will appear on your
computer as a driver named ‘MICROBIT’. Please note that it is not an
ordinary USB disk as shown below.
|image2|
**Step 2: writing programs**
View the link https://makecode.microbit.org/ in your browser.
Click “New Project”.
The dialog box “Create a Project” appears, fill it with “heartbeat” and
click ‘Create “√” to edit.
(If you are running Windows 10 system, it is also viable to edit on the
APP MakeCode for micro:bit , which is exactly like editing in the
website. And the link to the APP is
https://www.microsoft.com/zh-cn/p/makecode-for-micro-bit/9pjc7sv48lcx?ocid=badgep&rtc=1&activetab=pivot:overviewtab)
|image3|
|image4|
Write a set of micro:bit code. You can drag some modules in the Blocks
to the editing area and then run your program in Simulator of MakeCode
editor as shown in the picture below which demonstrates how to edit
‘heartbeat’ program .
As for loading test code , please turn to Chapter 5.5.
And introduction of Makecode is on the next chapter 5.2.
|image5|
**Step 3: download test code**
If your computer is Windows 10 and you have downloaded the APP MakeCode
for micro:bit to write program, what you will have to do to download the
program to your Micro: Bit main board V2 is merely clicking the
‘Download’ button, then all is done.
If you are writing programs through the website, following these steps:
Click the ‘Download’ in the editor to download a “hex” file, which is a
compact program format that the Micro: Bit main board can read.Once the
hexadecimal file is downloaded, copy it to your board V2 just like the
process that you copy the file to the USB drive. If you are running
Windows system, you can also right-click and select ‘Send to → Microbit
(E) ‘to copy the hex file to the Micro: Bit main board V2.
|image6|
You can also directly drag the “hex” file onto the MICROBIT (E) disk.
|image7|
|image8|
During the process of copying the downloaded hex file to the Micro: Bit
main board V2, the yellow signal light on the back side of the board
flashes. When the copy is completed, the yellow signal light will stop
flashing and remain on.
**Step 4: run the program**
After the program is uploaded to the Micro: Bit main board V2, you could
still power it via the USB cable or change to via an external power. The
5 x 5 LED dot matrix on the board displays the heartbeat pattern.
|image9|
Power via micro USB cable
|image10|
Power via external power(3V)
**Step 5:other programming languages**
This chapter has described how to use the Micro: Bit main board V2.
But except for the Makecode graphical programming introduced you can
also write Micro: Bit programs in other languages. Go to the link:
https://microbit.org/code/ to know about other programming languages ,
or view the link: https://microbit.org/projects/, to find something you
want to have a go.
3.3 Makecode
------------
Browse https://makecode.microbit.org/ and enter Makecode online editor
or open the APP MakeCode for micro:bit of Windows 10.
|image11|
Click“New Project”, and input“heartbeat”,then enter Makecode editor, as
shown below:
|image12|
There are blocks“on start”and“forever”in the code editing area.
When the power is plugged or reset,“on start”means that the code in the
block only executes once, while“forever”implies that the code runs
cyclically.
3.4 Quick Download
------------------
As mentioned before, if your computer is Windows 10 and you have
downloaded the APP MakeCode for micro:bit to write programs, the program
written can be quickly downloaded to the Micro: Bit main board V2 by
selecting ‘Download’.
While it is a little more trickier if you are using a browser to enter
makecode. However, if you use Google Chrome, suitable for Linux,macOS
and Windows 10, the process can be quicker too.
We use the webUSB function of Chrome to allow the internet page to
access the Components device connected USB. You could refer to the
following steps to connect and pair devices.
**Device pairing :**
Connect micro:bit to your computer by USB cable.
Click“…”beside“Download”and click“Pair device”.
|image13|
Then click another“Pair device”as shown below.
|image14|
Then select ‘’BBC micro:bit CMSIS-DPA” and click “Connect”. If ‘’BBC
micro:bit CMSIS-DPA”does not show up for selection, please refer to
`https://makecode.microbit.org/device/usb/webusb/troubleshoot `__
We also provide |image15|\ in the resource link.
What’s more, if you don’t know how to update the firmware of micro:bit,
refer to the link:
`https://microbit.org/guide/firmware/ `__
or browse folder\ |image16|\ we provide.
|image17|
Then click ”Download”. The program is directly downloaded to Micro: Bit
main board V2 and the sentence “Download completed!” appears.
|image18|
3.5 Input test code
-------------------
We provide hexadecimal code files (project files) for each project. The
file contains all the contents of the project and can be imported
directly, or you can manually drag the code blocks to complete the
program for each project. For simple projects, dragging a block of code
to complete the program is recommended. For complex projects, it is
recommended to conduct the program by importing the hexadecimal code
file we provide.
Let’s take the “Heatbeat” project as an example to show how to load the
code.
Open the Web version of Makecode or the Windows 10 App version of
Makecode.
|image19|
Click “Import File”;
|image20|
|image21|
Select“ ../Makecode Code/Project 1\_ Heart beat/Project 1\_ Heart
beat.hex” ;
Then click “Go ahead”.
|image22|
|image23|
In addition to importing the test code file provided into the Makecode
compiler above, you can also drag the the test code file provided into
the code editing area of the Makecode compiler, as shown in the figure
below:
|image24|
After a few seconds, it is done.
|image25|
Note: if your computer system is Windows7 or 8 instead of Windows 10,
the pairing cannot be done via Google Chrome.
Therefore, digital signal or analog signal of sensors and modules cannot
be shown on the serial port simulator. However, you need to read the
corresponding digital signal or analog signal.So what can we do? You can
use the CoolTerm software to read the serial port data of the micro:bit.
3.6 CoolTerm Installation
-------------------------
CoolTerm program is used to read the data on serial port.
Please Download CoolTerm program here:
|image26|
1. After the download, we need to install CoolTerm program file, below
is Window system taken as an example.
2. Choose“win”to download the zip file of CoolTerm
3. Unzip file and open it. (also suitable for Mac and Linux system)
|image27|
|image28|
Double-click |image29|.
|image30|
The functions of each button on the Toolbar are listed below:
http://wiki.keyestudio.com/index.php/File:IDE.png
|image31|
+------------------------------+---------------------------------------+
| ICON | FUCTION |
+==============================+=======================================+
| |image32| | Opens up a new Terminal |
+------------------------------+---------------------------------------+
| |image33| | Opens a saved Connection |
+------------------------------+---------------------------------------+
| |image34| | Saves the current Connection to disk |
+------------------------------+---------------------------------------+
| |image35| | Opens the Serial Connection |
+------------------------------+---------------------------------------+
| |image36| | Closes the Serial Connection |
+------------------------------+---------------------------------------+
| |image37| | Clears the Received Data |
+------------------------------+---------------------------------------+
| |image38| | Opens the Connection Options Dialog |
+------------------------------+---------------------------------------+
| |image39| | Displays the Terminal Data in |
| | Hexadecimal Format |
+------------------------------+---------------------------------------+
| |image40| | Displays the Help Window |
+------------------------------+---------------------------------------+
3.7 Projects
------------
(Note: project 1 to 12 will be conducted with the built-in sensors and
LED dot matrix of the Micro:bit main board V2)
.. toctree::
:maxdepth: 1
Project/Project1
Project/Project2
Project/Project3
Project/Project4
Project/Project5
Project/Project6
Project/Project7
Project/Project8
Project/Project9
Project/Project10
Project/Project11
Project/Project12
Project/Project13
Project/Project14
Project/Project15
Project/Project16
Project/Project17
Project/Project18
Project/Project19
Project/Project20
Project/Project21
Project/Project22
Project/Project23
Project/Project24
Project/Project25
Project/Project26
Project/Project27
Project/Project28
Project/Project29
Project/Project30
Project/Project31
Project/Project32
.. |image1| image:: media/image-20260126111812564.png
.. |image2| image:: media/image-20260122142359783.png
.. |image3| image:: media/image-20260122142552103.png
.. |image4| image:: media/image-20260122142559945.png
.. |image5| image:: media/image-20260122142618761.png
.. |image6| image:: media/image-20260122142651938.png
.. |image7| image:: media/image-20260122142703201.png
.. |image8| image:: media/image-20260122142834926.png
.. |image9| image:: media/image-20260122142919294.png
.. |image10| image:: media/image-20260122142906983.png
.. |image11| image:: media/image-20260122143036081.png
.. |image12| image:: media/image-20260122143045334.png
.. |image13| image:: media/image-20260122143332393.png
.. |image14| image:: media/image-20260122143342678.png
.. |image15| image:: media/image-20260122143513917.png
.. |image16| image:: media/image-20260122143534066.png
.. |image17| image:: media/image-20260122143549564.png
.. |image18| image:: media/image-20260122143600451.png
.. |image19| image:: media/image-20260122143720079.png
.. |image20| image:: media/image-20260122143730743.png
.. |image21| image:: media/image-20260122143735611.png
.. |image22| image:: media/image-20260122143753754.png
.. |image23| image:: media/image-20260122143759866.png
.. |image24| image:: media/image-20260122143811810.png
.. |image25| image:: media/image-20260122143926452.png
.. |image26| image:: media/image-20260126104117622.png
.. |image27| image:: media/image-20260122144440695.png
.. |image28| image:: media/image-20260122144448540.png
.. |image29| image:: media/image-20260122144804245.png
.. |image30| image:: media/image-20260122144817521.png
.. |image31| image:: media/image-20260122144830969.png
.. |image32| image:: media/image-20260122144911879.png
.. |image33| image:: media/image-20260122144918726.png
.. |image34| image:: media/image-20260122144926444.png
.. |image35| image:: media/image-20260122145032626.png
.. |image36| image:: media/image-20260122145042630.png
.. |image37| image:: media/image-20260122145048766.png
.. |image38| image:: media/image-20260122145055201.png
.. |image39| image:: media/image-20260122145110485.png
.. |image40| image:: media/image-20260122145118597.png